<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*,java.io.*, java.sql.*, dbAccess.*"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content
-Type" content="text/html; charset=ISO-8859-1" />
<title>Appointments for <%=session.getAttribute("Name")%></title>
<link rel="stylesheet" type="text/css" href="css_files/style.css" />
<script type="text/javascript">
function changeNumberofDays()
{
	var mylist = document.forms["frmApptSearch"].cmbMonth;
	var month = mylist.selectedIndex;
	if ((month == 0) || (month == 2) || (month == 4) || (month == 6) || (month == 7) || (month == 9) || (month == 11))
	{
		var days = document.forms["frmApptSearch"].cmbDate;
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 31; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else if (month == 1)
	{
		var days = document.forms["frmApptSearch"].cmbDate;
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 28; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else
	{
		var days = document.forms["frmApptSearch"].cmbDate;
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 30; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
}
	
</script>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="150" height="125" valign="top"><img src="images/caduceus.gif" alt="" name="LogoLeft" width="150" height="125" id="LogoLeft" style="background-color: #0033FF" /></td>
    <td width="692" align="center" valign="middle"><h1 align="center">CADUCEUS HOSPITAL</h1></td>
    <td width="157" valign="top"><img src="images/hospital.jpg" alt="" name="LogoRight" width="150" height="125" id="LogoRight" style="background-color: #0033FF" /></td>
  </tr>
  <tr>
    <td height="19" colspan="2" valign="top">Welcome <%=session.getAttribute("Name")%>&nbsp;<%=new java.util.Date() %></td>
    <td align="right">
		<a href="home.jsp" title="Logout">Logout</a>
	</td> 
  </tr>
</table>

<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
    <tr>
    	<td width="259" valign="top"><p class="style2"><p><strong>Quicklinks</strong></p>
    <p><a href="patient2appt.jsp">View My Appointments</a></p>
    <p><a href="editPatient.jsp?callerId=patientHome">Change My Personal Information</a></p>
    <p><a href="http://www.webmd.com">WebMD</a></p>
    <p><a href="patientHome.jsp">Back to Homepage</a></p>
    <p>&nbsp;</p></td>
    	<td width="740" rowspan="2" valign="top" class="style2",><h3><span class="style2"><strong>Appointments For <%=session.getAttribute("Name")%></strong></span></h3>
    	  <table width="100%" border="1">
			<thead>
			<tr>
				<td><strong>
				  Appointment ID
				</strong></td>
				<td>
				  <strong>Date</strong> </td>
				<td><strong>
				  Start Time
				</strong></td>
				<td><strong>
				  End Time
				</strong></td>
				<td>
				  <strong>Building</strong> </td>
				<td><strong>
				  Room Number
				</strong></td>
				<td><strong>
				  Doctor Name
				</strong></td>
				<td><strong>
				  Visitation Record
				</strong></td>
			</tr>
			</thead>
			<tbody>
			<%
			Login lgn = new Login();
			ResultSet rs;
			int appointmentId = 0;
			java.util.Date d = new java.util.Date();
			java.sql.Time startTime = Time.valueOf("00:00:00");
			java.sql.Time endTime = Time.valueOf("00:00:00");
			String building = "unknown";
			String roomNum = "unknown";
			String defaultDocName = "unknown";
			int visitId = 0;

			rs = lgn.getAllPatientAppointments((Integer)session.getAttribute("patientId"));
			if (rs != null)
			{
				Boolean even = true;
				String colorCode = "white";
				while (rs.next())
				{
					if (even)
					{
						colorCode = "white";
						even = false;
					}
					else
					{
						colorCode = "#E3E4FA";
						even = true;
					}
					appointmentId = rs.getInt("tbl_appointment.appointmentId");
					d = rs.getDate("tbl_appointment.Date");
					startTime = rs.getTime("tbl_appointment.StartTime");
					endTime = rs.getTime("tbl_appointment.EndTime");
					building = rs.getString("tbl_appointment.Building");
					roomNum = rs.getString("tbl_appointment.Room");
					defaultDocName = rs.getString("DocFirstName") + " " + rs.getString("DocLastName");
					visitId = rs.getInt("tbl_visit.VisitId");
			%>
			<tr bgcolor=<%=colorCode%>>
				<td>
					<%=appointmentId%>				
				</td>
				<td>
					<%=d%>				
				</td>
				<td>
					<%=startTime.toString()%>				
				</td>
				<td>
					<%=endTime.toString() %>				
				</td>
				<td>
					<%=building%>				
				</td>
				<td>
					<%=roomNum%>				
				</td>
				<td>
					<%=defaultDocName%>				
				</td>
				<td>
        			<%
        				if (visitId != 0)
        				{
        			%>
        				<a href = "patientVisit.jsp?vId=<%=visitId%>&callerId=patient2appt">View Details</a>
        					<%
        				}
        				else 
        				{		
        			%>
        				N/A.
        					
        			<%}
        			%>   			
        		</td>
			</tr>
			
			<%	
				}
			}
			%>
			</tbody>
		</table>	</td>
  </tr>
  
  <tr>
    <td height="220" valign="top" class="style2"></td>
  </tr>
</table>
</body>
</html>